package com.project_doctor.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.project_doctor.pojo.AnnouncementReply;
import com.project_doctor.pojo.Dto.AnnouncementReplyDTO;
import com.project_doctor.service.AnnouncementReplyService;
import com.project_doctor.mapper.AnnouncementReplyMapper;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

import static java.time.LocalDateTime.now;


/**
* @author 龙龙与贝儿
* @description 针对表【t_announcement_reply】的数据库操作Service实现
* @createDate 2025-06-05 15:54:37
*/
@Service
public class AnnouncementReplyServiceImpl extends ServiceImpl<AnnouncementReplyMapper, AnnouncementReply>
    implements AnnouncementReplyService{

    @Autowired
    private AnnouncementReplyMapper announcementReplyMapper;

    @Override
    public Long addReply(AnnouncementReplyDTO dto) {
        AnnouncementReply reply = new AnnouncementReply();
        BeanUtils.copyProperties(dto, reply);
        reply.setCreateTime(new Date());
        announcementReplyMapper.insert(reply);
        return reply.getId();
    }

    @Override
    public List<AnnouncementReply> listReplies(Long announcementId) {
        List<AnnouncementReply> replies = announcementReplyMapper.selectByAnnouncementId(announcementId);
        return replies;
    }
}




